let path = "http://localhost:8080/Saxon_Blog_war/";
let userName = document.getElementById("userName");
userName={"status":"false"}
let account = document.getElementById("userAccount");
account={"status":"false"}

//检查是否有重复的用户名
function register_userName() {
    $.get({
        url: path+"/register/username",
        data: {"userName": $("#userName").val()},
        success: function (data) {
            if (data === "false") {
                $("#userName").addClass("is-valid");
                $("#userName").removeClass("is-invalid");
                $("#userName_span").attr("hidden","true")
                userName.status="true"
            } else if (data==="error") {
                $("#userName").addClass("is-invalid")
                $("#userName").removeClass("is-valid")
                $("#userName_span").removeAttr("hidden")
                $("#userName_span").html("你的用户名重复，请修改")
            } else {
                $("#userName").addClass("is-invalid")
                $("#userName").removeClass("is-valid")
                $("#userName_span").removeAttr("hidden")
                $("#userName_span").html("请确保你的用户名不为空")
            }
        }
    })
}
//检查是否是第一个注册的账号
function register_useraccount() {
    $.get({
        url: "http://localhost:8080/Saxon_Blog_war//register/userAccount",
        data: {"userAccount": $("#userAccount").val()},
        success: function (data) {
            if (data === "false") {
                $("#userAccount").addClass("is-valid");
                $("#userAccount").removeClass("is-invalid");
                $("#userAccount_span").attr("hidden","true")
                account.status="true";
            } else if (data==="error") {
                $("#userAccount").addClass("is-invalid")
                $("#userAccount").removeClass("is-valid")
                $("#userAccount_span").removeAttr("hidden")
                $("#userAccount_span").html("亲，你的账户已存在请修改")
            } else {
                $("#userAccount").addClass("is-invalid")
                $("#userAccount").removeClass("is-valid")
                $("#userAccount_span").removeAttr("hidden")
                $("#userAccount_span").html("请输入你的账户名")
            }
        }
    })
}
//检查信息是否完整
function check_submit() {
    if (userName.status==="true"&&account.status==="true"){
        return true;
    }else {
        alert("请再次确认信息的正确")
        return false;
    }
}
